<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="assets/css/stylesheet.css">
<link rel="stylesheet" type="text/css" href="assets/css/fontawesome.min.css">

<title>SAT>IP Config Page</title>

<script src="assets/js/menu.js"></script>
<script src="assets/js/loadxmldoc.js"></script>
<script src="assets/js/postxmldoc.js"></script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/addtableentry.js"></script>
<script>
	var autoload = 1;
	var content;
	var once = 0;

	function buildcontent(xmlDoc) {
		var length = 1;
		var page = "";
		page += "<table class=\"table table-bordered table-sm\">";
		page += "<thead></thead>";
		page += "<tbody>";
		if (content == "general") {
			page += addTableLineText("IP Address", xmlDoc, "ipaddress");
			page += addTableLineEntry("HTTP Port", xmlDoc, "httpport");
			page += addTableLineEntry("RTSP Port", xmlDoc, "rtspport");
			page += addTableLineEntry("SSDP Interval (sec)", xmlDoc, "input1");
			page += addTableLineEntry("Satip Channel list (m3u)", xmlDoc, "xsatipm3u");
			page += addTableLineEntry("Satip Description XML", xmlDoc, "xmldesc");
			page += addTableLineEntry("Path to the Web-GUI", xmlDoc, "webPath");
			page += addTableLineEntry("Path to store Application Data", xmlDoc, "appDataPath");
			page += addTableLineEntry("Log messages to syslog", xmlDoc, "syslog");
			page += addTableLineEntry("Log Debug messages", xmlDoc, "logDebug");
		} else if (content == "oscam"/* && xmlDoc.getElementsByTagName("OSCamEnabled").length != 0*/) {
			page += addTableLineEntry("OSCam server Enabled", xmlDoc, "OSCamEnabled");
			page += addTableLineEntry("OSCam server name", xmlDoc, "OSCamServerName");
			page += addTableLineEntry("OSCam server IP", xmlDoc, "OSCamIP");
			page += addTableLineEntry("OSCam server PORT", xmlDoc, "OSCamPORT");
			page += addTableLineEntry("OSCam Aadapter offset", xmlDoc, "AdapterOffset");
			page += addTableLineEntry("Rewrite PMT", xmlDoc, "RewritePMT");
		}
		page += "</tbody>";
		page += "</table>";
		return page;
	}
	function updatePage() {
		loadXMLDoc("SatPI.xml");
	}
	// function called when xml is loaded
	function xmlloaded(xml) {
		if (once == 0) {
			once = 1;
			// Catch events from Tab
			$(".nav-tabs a").click(function() {
				$(this).tab('show');
			});
			$('.nav-tabs a').on('shown.bs.tab', function(event) {
				var href = $(event.target).attr("href");
				// remove # from href
				content = href.substr(1, href.length)
				updatePage();
			});
		}

		if (autoload == 1) {
			var page = buildcontent(xml)
			document.getElementById(content).innerHTML = page;
		}
	}
</script>

</head>
<body>
<div id="menu"></div>

<div class="p-1">
<div class="window-start container border rounded-bottom">
	<div class="window-name">
		<p>Configuration</p>
	</div>
	<div class="p-1 table-responsive table-text-size">
		<ul class="nav nav-tabs">
			<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#general">General</a></li>
			<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#oscam">OSCam</a></li>
		</ul>
		<div class="tab-content">
			<div id="general" class="tab-pane fade show active"></div>
			<div id="oscam" class="tab-pane fade"></div>
		</div>
	</div>
	<script>
		// make menu
		document.getElementById("menu").innerHTML = buildmenu();
		setMenuItemActive("config");

		content = "general";
		updatePage();

		// Call the ajax refresh each refresh_time seconds
		var refresh_time = 3000;
//		setInterval("updatePage()", refresh_time);
	</script>
</div>
</div>
</body>
</html>
